package com.test.pdproject.swwager2Api.app;


import com.alibaba.fastjson.JSONObject;
import com.test.pdproject.constant.Page;
import com.test.pdproject.constant.PageData;
import com.test.pdproject.controller.BaseController;
import com.test.pdproject.service.BankService;
import com.test.pdproject.util.AppResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping(value = "/swager/API")
@Api("SwwagerController相关api")
public class SwwagerController extends BaseController {
    @Resource
    private BankService bankService;
    @ResponseBody
    @RequestMapping(value = "/findBankList", method = RequestMethod.GET, produces = {"application/json; charset=utf-8", "application/json"})
    @ApiOperation(value = "获取银行卡列表", httpMethod = "GET", notes = "仅1和2有正确返回")
    @ApiImplicitParam(paramType = "header", name = "deviceToken", value = "deviceToken", required = false, dataType = "String")
    public AppResponse findBank(Page page) throws Exception {
        JSONObject data = new JSONObject();
        List<PageData> fist = bankService.searchlistPage(page);
        if (fist.size() > 0) {
            data.put("fist", fist);
        }
        List<PageData> sceond = bankService.searchlist2Page(page);
        if (sceond.size() > 0) {
            data.put("sceond", sceond);
        }
        System.out.println(fist.toString());
        return AppResponse.success(data);
    }
}
